﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using TravelLink.DAL;

namespace TravelLink.WebApp.Admin
{
    public partial class AdminCustomPage : System.Web.UI.Page
    { 
        protected void Page_Load(object sender, EventArgs e)
        { 
            this.CheckResponse((4000 + int.Parse(this.Request["id"])).ToString());
            if (!this.IsPostBack)
            { 
                string html=string.Empty;
                TravelLinkDBDataContext dc = DataContextFactory.Create();
                TL_CustomPage item = dc.TL_CustomPage.Where(t => t.ID.ToString() == this.Request["id"]).FirstOrDefault();
                 if (item != null)
                 {
                     html=item.HTML;
                 }
                 this.ASPxHtmlEditor1.Html = html;
            }
        }

        protected void ASPxButton1_Click(object sender, EventArgs e)
        {
            var dc = DataContextFactory.Create();
            var item = dc.TL_CustomPage.Where(t => t.ID.ToString() == this.Request["id"]).FirstOrDefault();
            if (item != null)
            {
                item.HTML = this.ASPxHtmlEditor1.Html;
                dc.SubmitChanges();
            }
        }
    }
}